@extends('manage.layout')

@section('content')
    <section class="content-header">
        <h1>
            线索列表
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Clue</a></li>
            <li class="active">Clue List</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">内容</h3>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>权重</th>
                                <th>创建时间</th>
                                <th>线索名</th>
                                <th>公司</th>
                                <th>联系方式</th>
                                <th>优先级</th>
                                <th>地点</th>
                                <th>提供者</th>
                                <th>跟进者</th>
                                <th>来源</th>
                                {{--<th>状态</th>--}}
                                <th>备注</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($clue as $c)
                            <tr>
                                <td>{{ $c['id'] }}</td>
                                <td>{{ $c['rank'] }}</td>
                                <td>{{ $c['create_time'] }}</td>
                                <td>{{ $c['name'] }}</td>
                                <td>{{ $c['company'] }}</td>
                                <td>{{ $c['phone'] }}</td>
                                <td>
                                    @if($c['priority'] == 0)一般
                                    @elseif($c['priority'] == 1)重要
                                    @endif
                                </td>
                                <td>{{ $c['location'] }}</td>
                                <td>{{ $c['provider'] }}</td>
                                <td>{{ $c['recriver'] }}</td>
                                <td>
                                    @if($c['source'] ==0 )主动来电
                                    @elseif($c['source'] ==1)网上收集
                                    @elseif($c['source'] ==2)朋友推荐
                                    @elseif($c['source'] ==3)销售人员
                                    @endif
                                </td>
                                {{--<td>--}}
                                    {{--@if($c['status'] == 0)有效--}}
                                    {{--@elseif($c['status'] == 1)无效--}}
                                    {{--@endif--}}
                                {{--</td>--}}
                                <td>{{ $c['remark'] }}</td>
                                <td>

                                    {{--<a id="status" class="btn btn-success btn-xs"  href="{{ url('clueEdit/'.$c['id']) }}">进行<a>--}}
                                        <div class="btn-group">
                                            <button type="button" class="btn btn-info btn-sm">@if($c['status'] === 0)无效@elseif($c['status'] === 1)停止@elseif($c['status'] === 2)作废@elseif($c['status'] === 3)暂停@elseif($c['status'] === 4)进行@endif</button>
                                            <button id="button" type="button" class="btn btn-info btn-sm dropdown-toggle" data-toggle="dropdown">
                                                <span class="caret"></span>
                                                <span class="sr-only">Toggle Dropdown</span>
                                            </button>
                                            <ul class="dropdown-menu" role="menu">
                                                <li><a href="javascript:clueStatus('{{ $c['id'] }}',0)">无效</a></li>
                                                <li><a href="javascript:clueStatus('{{ $c['id'] }}',1)">停止</a></li>
                                                <li><a href="javascript:clueStatus('{{ $c['id'] }}',2)">作废</a></li>
                                                <li><a href="javascript:clueStatus('{{ $c['id'] }}',3)">暂停</a></li>
                                                <li><a href="javascript:clueStatus('{{ $c['id'] }}',4)">进行</a></li>

                                            </ul>
                                        </div>
                                        {{--<a class="btn btn-danger btn-xs" href="javascript:delCate({{ $c['id'] }})">删除<a>--}}
                                        {{--@if($c['status'] == 1)--}}
                                            {{--<a class="btn btn-danger btn-xs" href="javascript:clueStatus('{{ $c['id'] }}',0)">禁用<a>--}}
                                        {{--@elseif($c['status'] == 0)--}}
                                            {{--<a class="btn btn-success btn-xs" href="javascript:clueStatus('{{ $c['id'] }}',1)">启用<a>--}}
                                        {{--@endif--}}
                                </td>
                            </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
@stop
@section('script')
    <script>
        //状态隐藏
        $(function(){
            $("#status").hover(function(){
                $("#ul").show();
            },function(){
                $("#ul").hide();
            })
        })

        //禁用,启用
        function clueStatus(id,status) {
            console.log(id);
            console.log(status);
            $.ajax({
                url: '/clue/clueStatus',
                type: "GET",
                data: {id:id,status:status},
                dataType: "json",
                success: function(res) {
                    console.log(res);
                    if(res.code == 101) {
//
                        layer.msg(res.msg, {time:1500, icon:5})
                    }
                    if(res.code == 4) {
//                        window.location.href=window.location.href;
                        layer.msg(res.msg, {time:1500, icon:6});
                    }
                    if(res.code == 3) {
//                        window.location.href=window.location.href;
                        layer.msg(res.msg, {time:1500, icon:6});
                    }
                    else {
                        layer.msg(res.msg, {time:1500, icon:6});
//                        window.location.href=window.location.href;
                    }
                }
            });
        }
    </script>
@stop